#include "io_led_stm32.h"
#include <stdio.h>

// include"stm32f1xx_io.h"
#define GPIO_WriteOutputPort(GPIOx, PortValue)  (void*)0
#define GPIO_ReadOutputPort(GPIOx)  (void*)0


int set_io_led_stm32(IoLedStm32* self,  int data)
{
    PRINT_FILE_LINE_FUNC();
    //GPIO_WriteOutputPort(self->io_port, data);
    self->io_level = data;
    printf("set STM32 IO_%d = %d\n", self->io_port, data);
    return 0;
}

int read_io_led_stm32(IoLedStm32* self,  int *data)
{
    PRINT_FILE_LINE_FUNC();
    //*data = GPIO_ReadOutputPort(self->io_port);
    *data = self->io_level;
    printf("read STM32 IO_%d is %d\n", self->io_port, *data);
    return 0;
}

IoLed_i io_led_stm32_interface = {
    .io_set  = (io_led_set_fn_t)set_io_led_stm32,
    .io_read = (io_led_read_fn_t)read_io_led_stm32
};

int init_io_led_stm32(IoLedStm32* self)
{
    PRINT_FILE_LINE_FUNC();
    self->interface = &io_led_stm32_interface;
    self->io_port = LED_IO_PORT;
    self->io_level = 1;
    return 0;
}
